/*
 * @Author: your name
 * @Date: 2021-12-22 18:41:30
 * @LastEditTime: 2021-12-22 19:34:14
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \briup_am\am-server\app\controller\team.js
 */
const { Controller } = require('egg');
const Message = require('../utils/Message')

/**
 * @Controller team-controller:球队相关接口
*/

class TeamController extends Controller {
      /**
   * @Router get /team/pageQuery
   * @summary 分页查询球队信息
   * @request query string *page
   * @request query string *pageSize
   * @apikey
  */

  async pageQuery () {
    const { ctx, service } = this
    const teamsVM = await service.team.pageQuery(ctx.query)

    ctx.body = Message.success(teamsVM)
  }
   /**
   * @Router post /team/saveOrUpdate
   * @summary 保存或修改球队信息
   * @request query number id
   * @request query string *team_nane
   * @request query string *create_time
   * @request query string *coach
   * @request query string *captain
   * @apikey
  */
    async saveOrUpdate () {
        const { ctx, service } = this
        // 接受用户请求 
        // 获取用户参数 ctx.query 
        // 调用service查询
        await service.team.saveOrUpdate(ctx.query)
        ctx.body = Message.success("操作成功")
      }
      /**
   * @Router get /team/findDeviceDetail
   * @summary 查询队员详情
   * @request query string *id 球队id
   * @apikey
  */
  async findDeviceDetail () {
    const { ctx, service } = this
    ctx.validate({
      id: 'string'
    }, ctx.query)
    const detail = await service.team.findDeviceDetail(ctx.query.id)

    ctx.body = Message.success(detail)
  }
}

module.exports = TeamController;